

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>yubihsm.exceptions &mdash; python-yubihsm 2.1.0 documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> python-yubihsm
          

          
          </a>

          
            
            
              <div class="version">
                2.1
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">python-yubihsm</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../index.html">Module code</a> &raquo;</li>
        
      <li>yubihsm.exceptions</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for yubihsm.exceptions</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright 2016-2018 Yubico AB</span>
<span class="c1">#</span>
<span class="c1"># Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span>
<span class="c1"># you may not use this file except in compliance with the License.</span>
<span class="c1"># You may obtain a copy of the License at</span>
<span class="c1">#</span>
<span class="c1">#     http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1"># Unless required by applicable law or agreed to in writing, software</span>
<span class="c1"># distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span>
<span class="c1"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<span class="c1"># See the License for the specific language governing permissions and</span>
<span class="c1"># limitations under the License.</span>

<span class="sd">&quot;&quot;&quot;Exceptions thrown by this library.&quot;&quot;&quot;</span>


<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">absolute_import</span>

<span class="kn">from</span> <span class="nn">.defs</span> <span class="kn">import</span> <span class="n">ERROR</span>


<div class="viewcode-block" id="YubiHsmError"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.exceptions.YubiHsmError">[docs]</a><span class="k">class</span> <span class="nc">YubiHsmError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Baseclass for YubiHSM errors.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="YubiHsmConnectionError"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.exceptions.YubiHsmConnectionError">[docs]</a><span class="k">class</span> <span class="nc">YubiHsmConnectionError</span><span class="p">(</span><span class="n">YubiHsmError</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;The connection to the YubiHSM failed.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="YubiHsmDeviceError"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.exceptions.YubiHsmDeviceError">[docs]</a><span class="k">class</span> <span class="nc">YubiHsmDeviceError</span><span class="p">(</span><span class="n">YubiHsmError</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;The YubiHSM returned an error code.</span>

<span class="sd">    :param int code: The device error code.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">code</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">code</span> <span class="o">=</span> <span class="n">ERROR</span><span class="p">(</span><span class="n">code</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">YubiHsmDeviceError</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="s2">&quot;</span><span class="si">{0.name}</span><span class="s2"> (error code 0x</span><span class="si">{0.value:02x}</span><span class="s2">)&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">code</span><span class="p">)</span>
        <span class="p">)</span></div>


<div class="viewcode-block" id="YubiHsmInvalidRequestError"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.exceptions.YubiHsmInvalidRequestError">[docs]</a><span class="k">class</span> <span class="nc">YubiHsmInvalidRequestError</span><span class="p">(</span><span class="n">YubiHsmError</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;The request was not able to be sent to the YubiHSM.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="YubiHsmInvalidResponseError"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.exceptions.YubiHsmInvalidResponseError">[docs]</a><span class="k">class</span> <span class="nc">YubiHsmInvalidResponseError</span><span class="p">(</span><span class="n">YubiHsmError</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;The YubiHSM returned an unexpected response.&quot;&quot;&quot;</span></div>


<div class="viewcode-block" id="YubiHsmAuthenticationError"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.exceptions.YubiHsmAuthenticationError">[docs]</a><span class="k">class</span> <span class="nc">YubiHsmAuthenticationError</span><span class="p">(</span><span class="n">YubiHsmError</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Authentication failed.&quot;&quot;&quot;</span></div>
</pre></div>

           </div>
           
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2018, Yubico.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>